﻿<navigation:Page x:Class="Groceries.Views.ShoppingListDetails"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           xmlns:datagrid="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
           xmlns:riacontrols="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Ria"
           xmlns:ds="clr-namespace:Groceries.Web.Services"
           xmlns:riadata="clr-namespace:System.Windows.Data;assembly=System.Windows.Controls.Ria"
           xmlns:dataform="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"
           xmlns:activity="clr-namespace:System.Windows.Controls;assembly=ActivityControl"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="ShoppingListDetails Page">
  <Grid x:Name="LayoutRoot">
    <Grid.Resources>
      <ds:GroceriesDomainContext x:Key="groceriesDomainContext" />
    </Grid.Resources>

    <riacontrols:DomainDataSource x:Name="shoppingListDetailsData" LoadSize="100" QueryName="GetItems" AutoLoad="True" DomainContext="{Binding Source={StaticResource groceriesDomainContext}}" >
    </riacontrols:DomainDataSource>

    <riacontrols:DomainDataSource x:Name="itemsData" LoadSize="100" QueryName="GetItems" AutoLoad="True" DomainContext="{Binding Source={StaticResource groceriesDomainContext}}" >
      <riacontrols:DomainDataSource.FilterDescriptors>
        <riadata:FilterDescriptorCollection>
          <riadata:FilterDescriptor PropertyPath="Name" Operator="Contains">
            <riacontrols:ControlParameter ControlName="txtNameFilter" ParameterName="Text" RefreshEventName="TextChanged"/>
          </riadata:FilterDescriptor>
        </riadata:FilterDescriptorCollection>
      </riacontrols:DomainDataSource.FilterDescriptors>
    </riacontrols:DomainDataSource>

    <ScrollViewer BorderThickness="0" VerticalScrollBarVisibility="Auto" Padding="0,12,0,12"
            Margin="-12">

      <StackPanel Margin="0,12,0,12" Orientation="Vertical">

        <TextBlock Text="Items in Shopping List" Style="{StaticResource HeaderTextStyle}"/>
        <datagrid:DataGrid x:Name="shoppingListDetailsGrid" MinHeight="100"
                       IsReadOnly="True" AutoGenerateColumns="False">
          <datagrid:DataGrid.Columns>

            <datagrid:DataGridTextColumn Header="Name" Width="200"
              Binding="{Binding Item.Name}" />

            <datagrid:DataGridTextColumn Header="Price" Width="100"
                Binding="{Binding Item.Price, StringFormat=C}" />

            <datagrid:DataGridTextColumn Header="Supplier" Width="200"
              Binding="{Binding Item.Supplier.Name}" />

            <datagrid:DataGridTextColumn Header="Amount" Width="100"
                Binding="{Binding Quantity}" />

          </datagrid:DataGrid.Columns>
        </datagrid:DataGrid>

        <TextBlock Text="Items" Style="{StaticResource HeaderTextStyle}"/>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,-16,0,0">
          <TextBlock Text="Name Filter: " VerticalAlignment="Center"/>
          <TextBox x:Name="txtNameFilter" Width="75" FontSize="11" Margin="4"/>
        </StackPanel>
        <datagrid:DataGrid x:Name="itemGrid" MinHeight="100"
                                   ItemsSource="{Binding ElementName=itemsData, Path=Data}" IsReadOnly="True">

        </datagrid:DataGrid>

      </StackPanel>

    </ScrollViewer>
  </Grid>
</navigation:Page>
